<!DOCTYPE html>
<html lang="en">

<head>
	<meta charset="UTF-8"/>
	<meta name="keywords" content="Script menu, script"/>
	<link rel="stylesheet" href="../../Shared/sty/standard.css"/>
	<script defer src="../../Shared/js/toc.js"></script>
	
	<title>Customize Script menu in CotEditor on Mac</title>
</head>

<body>

<h1>Customize Script menu in CotEditor on Mac</h1>

<p>You can change the order of scripts in the Script menu or assign keyboard shortcuts to scripts by modifying their filenames in the scripts folder.</p>


<section>
<h2>Order the items in the Script menu</h2>

<p>To arrange scripts in a specific order, add a number followed by a closing parenthesis, such as “01)”, at the beginning of the filename. This prefix is used only for sorting and doesn’t appear in the Script menu.</p>

<table>
	<caption>Example</caption>
	<thead>
		<tr><th>Filename</th><th>Show in the menu</th></tr>
	</thead>
	<tbody>
		<tr>
			<td><strong>01)</strong>Open File.scpt</td>
			<td>Open File</td>
		</tr>
	</tbody>
</table>
</section>


<section>
<h2>Add separators to the Scriipt menu</h2>

<p>A folder named “-” becomes a separator line in the Script menu. You can insert the separator at a specific position by adding a number and a closing parenthesis at the beginning of the folder name (for example, “02)-”).</p>
</section>


<section>
<h2>Put hidden files/folders</h2>

<p>Files or folders whose names begin with an underscore “_” don’t appear in the Script menu. You can use them to store settings files, library scripts, and other supporting items.</p>
</section>


<section>
<h2>Create submenus</h2>

<p>A script placed inside a folder within the scripts folder appears as an item in a submenu.</p>
</section>


<section>
<h2>Assign a keyboard shortcut to a script</h2>

<p>You can assign a keyboard shortcut to a script by adding dot “.” followed by modifier keys and a shortcut key before the file extension.</p>

<ul>
	<li><p>Shortcut keys are case sensitive. An uppercase letter means the Shift key must also be pressed. See the examples below to see how it works.</p></li>
	<li><p>The shortcut key must be a single letter and must come after the modifier keys. You cannot assign non-character keys such as <kbd>F1</kbd> or <kbd>Delete</kbd>.</p></li>
	<li><p>If a shortcut is already used by another function in CotEditor, the shortcut for the script is ignored.</p></li>
</ul>

<table>
	<caption>Modifier key notations</caption>
	<thead>
		<tr><th>Notation</th><th>Equivalent key</th></tr>
	</thead>
	<tbody>
		<tr><td>^</td><td><kbd>Control</kbd></td></tr>
		<tr><td>$</td><td><kbd>Shift</kbd></td></tr>
		<tr><td>~</td><td><kbd>Option</kbd></td></tr>
		<tr><td>@</td><td><kbd>Command</kbd></td></tr>
	</tbody>
</table>

<table>
	<caption>Examples</caption>
	<thead>
		<tr><th>Filename</th><th>Show in the menu</th><th>Shortcut</th></tr>
	</thead>
	<tbody>
		<tr>
			<td>Insert Text<strong>.@e</strong>.scpt</td>
			<td>Insert Text</td>
			<td><kbd>Command</kbd>-<kbd>E</kbd></td>
		</tr>
		<tr>
			<td>03)Insert Date<strong>.@~Y</strong>.scpt</td>
			<td>Insert Date</td>
			<td><kbd>Option</kbd>-<kbd>Shift</kbd>-<kbd>Command</kbd>-<kbd>Y</kbd></td>
		</tr>
	</tbody>
</table>


<h3>Set the same shortcut to multiple scripts</h3>

<p>When multiple scripts share the same keyboard shortcut, CotEditor gives priority to scripts in a subfolder whose name matches the syntax of the current document. This priority updates dynamically as the current document changes.</p>
</section>


<section id="cf">
<h2>See also</h2>
<ul>
	<li><a href="script_overview.html">Automate tasks with scripting in CotEditor on Mac</a></li>
</ul>
</section>

</body>
</html>
